package com.xuecheng.manage_course.controller;

import com.xuecheng.api.course.TeachplanControllerApi;
import com.xuecheng.framework.domain.course.Teachplan;
import com.xuecheng.framework.domain.course.TeachplanMedia;
import com.xuecheng.framework.domain.course.ext.TeachplanNode;
import com.xuecheng.framework.model.response.ResponseResult;
import com.xuecheng.manage_course.service.TeachplanService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.TreeSet;

@RestController
@RequestMapping("/course/teachplan")
public class TeachplanController implements TeachplanControllerApi {
    @Resource
    TeachplanService teachplanService;
    /**
     * 根据课程id查询课程计划
     *
     * @param courseId 课程id
     * @return 查询出的课程
     */
    @Override
    @GetMapping("/list/{courseId}")
    public TeachplanNode findTeachplanList(@PathVariable("courseId") String courseId) {
        return teachplanService.findTeachplanList(courseId);
    }

    /**
     * 添加课程计划
     *
     * @param teachplan 课程实体类
     * @return 响应结果
     */
    @Override
    @PostMapping("/add")
    public ResponseResult addTeachplan(@RequestBody Teachplan teachplan) {
        return  teachplanService.addTeachplan(teachplan);
    }

    /**
     * 保存课程计划和视频关联信息
     *
     * @param teachplanMedia 课程计划和视频关联
     * @return 结果
     */
    @Override
    @PostMapping("/saveMedia")
    public ResponseResult saveMedia(@RequestBody TeachplanMedia teachplanMedia) {
        return teachplanService.saveMedia(teachplanMedia);
    }
}
